<div class='fui-page fui-page-current'>
    <div class="fui-header">
		<div class="fui-header-left" onclick="window.history.go(-1);">
			<a class="back"></a>
		</div>
		<div class="title">绑定手机</div> 
		<div class="fui-header-right">&nbsp;</div>
    </div>
    <div class='fui-content' >
		<div class='fui-cell-group'>
			<div class='fui-cell' ng-if="pagedata.mobile">
				<div class='fui-cell-label'>已绑手机</div>
				<div style="float:left"><input class='fui-input' readonly="readonly" id='mobile' ng-model="pagedata.mobile"></div><div style="width:30%;float:right"><a href="javascript:;" class="label label-f60"  ng-click="pagedata.changemobile=1">重新绑定</a></div>
			</div>
			<div class='fui-cell' ng-if="pagedata.changemobile == 1 || !pagedata.mobile">
				<div class='fui-cell-label'>手机号</div>
				<div style="float:left"><input class='fui-input' id='mobile' ng-model="pagedata.item.mobile"></div><div style="width:30%;float:right"><a href="javascript:;" class="jylabel jylabel-f60" id="sms_code" ng-click="sendcode()">获取验证码</a></div>
			</div>
			<div class='fui-cell' ng-if="pagedata.changemobile == 1 || !pagedata.mobile">
				<div class='fui-cell-label'>验证码</div>
				<div ><input class='fui-input' id='yzm' ng-model="pagedata.item.yzm"></div>
			</div>
		</div>
		<a href="javascript:;" class='btn btn-success block' ng-click="post(pagedata.item,'post')">绑定</a>
    </div>
</div>
<script>
window.scope.sendcode=function(){
	var mobile=window.scope.pagedata.item.mobile;
	if(mobile==null){
		alert('请输入手机号！');
		return false;
	}
	if(mobile.length!=11){
		alert('请输入正确的手机号！');
		return false;
	}
	var d=$('#sms_code').text();
	if(d!='重新获取' && d!='获取验证码'){
		return false;
	}
	//var postdata={'p':'core','action':'smscode','mobile':mobile};
	window.scope.post({'mobile':mobile},'send_verifycode','',function(res){
		if(res=='success'){
			setTimeout(function(){countdown(59);},1000);
		}else{
			window.scope.message('验证码发送失败！');
		}
	});
}
function countdown(start){
		if(start>0){
			$('#sms_code').text(start+'后重新发送');
			start=start-1;
			setTimeout(function(){countdown(start);},1000);
		}else{
			
			$('#sms_code').text('重新获取');
		}
}
</script>
